static void
unicsv_fondle_header(char* ibuf)
{
+ // TODO: clean up this back and forth between QString and char*.
QString s;
char* buf = NULL;
int column;
* If we see a tab in that header, we decree it to be tabsep.
*/
unicsv_fieldsep = ",";
+ s = QString(ibuf); // main has set the codec to UTF-8.
if (s.contains('\t')) {
unicsv_fieldsep = "\t";
} else if (s.contains(';')) {
/* convert the header line into native ascii */
if (global_opts.charset != ascii) {
- buf = cet_str_any_to_any(ibuf, global_opts.charset, ascii);
+ buf = cet_str_any_to_any(CSTR(s), global_opts.charset, ascii); // CSTR goes back to UTF-8.
ibuf = buf;
}
break;
case fld_bng_zone:
- strncpy(bng_zone, s, sizeof(bng_zone) -1 );
+ strncpy(bng_zone, s, sizeof(bng_zone) -1);
strupper(bng_zone);
break;
QString t;
if (!s.isEmpty()) {
t = strenquote(s, UNICSV_QUOT_CHAR);
- // I'm not sure these three replacements are necessary; they're just a
- // slavish re-implementation of (what I think) the original C code
+ // I'm not sure these three replacements are necessary; they're just a
+ // slavish re-implementation of (what I think) the original C code
// was doing.
t.replace("\r\n", ",");
t.replace("\r", ",");
return;
}
QDateTime dt = idt;
- if (opt_utc) {
- //time += atoi(opt_utc) * SECONDS_PER_HOUR;
- dt = dt.addSecs(atoi(opt_utc) * SECONDS_PER_HOUR);
- dt = dt.toUTC();
- }
+ if (opt_utc) {
+ //time += atoi(opt_utc) * SECONDS_PER_HOUR;
+ dt = dt.addSecs(atoi(opt_utc) * SECONDS_PER_HOUR);
+ dt = dt.toUTC();
+ }
unicsv_print_str(dt.toString("yyyy/MM/dd hh:mm:ss"));
}